<div class="password-item">
    <input type="password" class="am-form-field old" placeholder="请输入旧取款密码" />
</div>
<div class="clue" style="font-size: 14px;  padding-left: 15px; padding-bottom: 10px;">
    如果未设置过取款密码，无需填写
</div>

<div class="password-item">
    <input type="password" class="am-form-field p1" placeholder="请输入新的取款密码" />
</div>

<div class="password-item">
    <input type="password" class="am-form-field p2" placeholder="请再次输新的取款密码" />
</div>

<div class="button2 bank">
    <button type="button" class="am-btn am-btn-primary btn-save">确定修改</button>
</div>
<style type="text/css">
    .password-item {
        margin: 10px 15px 10px 15px;
    }
    .password-item input {
        border: 1px solid #191919;
        color: #000;
        border-radius: 4px;
        background-color: #fff;
        color: #000;
    }
</style>

<script>
    $(".bank .btn-save").click(function() {
        if (!context.user) return;
        
        var old = $(".old").val().trim(),
            p1 = $(".p1").val().trim(),
            p2 = $(".p1").val().trim();
        if (old == '' && context.user.user.password) {
            alert2("请输入旧资金密码！");
            return;
        }
        if (p1 == '') {
            alert2("请输入新资金密码！");
            return;
        }
        if (p2 == '') {
            alert2('请再次输入新资金密码！');
            return;
        }
        if (p1 != p2) {
            alert2("两次密码不匹配，请重新输入！");
            return;
        }
        if (old != context.user.user.password && context.user.user.password) {
            alert2("旧资金密码错误！");
            return;
        }

        startLoading();
        CMD.modify_user_info(undefined, {
            password: p1,
        }, function() {
            stopLoading();
            alert2("资金密码修改成功！");
        })
    });
</script>